package com.wenli.graduate2022.wenliGreenShop.controller;

import com.wenli.graduate2022.wenliGreenShop.entity.PropertyValue;
import com.wenli.graduate2022.wenliGreenShop.service.servDao.PropertyValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author HuangHai
 * @date 2021/10/11 11:43
 */
@RestController
public class PropertyValueController {

    @Autowired
    PropertyValueService propertyValueService;

    @GetMapping("propertyValue/{id}")//产品的属性值
    public List<PropertyValue> findByProductId(@PathVariable("id") Integer id){
        return propertyValueService.findByProductId(id);
    }

    @PutMapping("propertyValue/{propertyValue}/{id}")//要修改的属性值与属性id
    public int update(@PathVariable("propertyValue") String propertyValue,@PathVariable("id") Integer id){
        return propertyValueService.update(propertyValue,id);
    }

    @PostMapping("propertyValue")
    public int insert(@RequestBody PropertyValue propertyValue){
        return propertyValueService.insert(propertyValue);
    }
}
